package com.maybach.workflow.core.manager.impl;

import com.maybach.util.query.support.PageResult;
import com.maybach.workflow.common.model.FlowSnapDO;
import com.maybach.workflow.common.query.FlowSnapQuery;
import com.maybach.workflow.core.dal.mapper.ext.FlowSnapExtMapper;
import com.maybach.workflow.core.manager.FlowSnapManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;


/**
 * Manager for FlowSnap.
 */

@Component
public class FlowSnapManagerImpl implements FlowSnapManager{
    protected Logger log = LoggerFactory.getLogger(this.getClass());

    
    @Autowired
    protected FlowSnapExtMapper flowSnapExtMapper;
    /**
     * query count by query condition.
     */
    @Override
    public int countByQuery(FlowSnapQuery query){
        return flowSnapExtMapper.countByQuery(query);
    }

    /**
     * delete by query condition.
     */
    @Override
    public int deleteByQuery(FlowSnapQuery query){
        return flowSnapExtMapper.deleteByQuery(query);
    }

    /**
     * delete by primary key.
     */
    @Override
    public int deleteByPrimaryKey(Long id){
        return flowSnapExtMapper.deleteByPrimaryKey(id);
    }

    /**
     * insert selective.
     */
    @Override
    public long insertSelective(FlowSnapDO record){
        return flowSnapExtMapper.insertSelective(record);
    }

    /**
     * select by query condition.
     */
    @Override
    public List<FlowSnapDO> selectByQuery(FlowSnapQuery query){
        return flowSnapExtMapper.selectByQuery(query);
    }

    /**
     * select by query condition with page.
    */
    @Override
    public PageResult<FlowSnapDO> selectByQueryWithPage(FlowSnapQuery query) {
        PageResult<FlowSnapDO> result = new PageResult<FlowSnapDO>();
        result.setPageSize(query.getPageSize());
        result.setPageNo(query.getPageNo());
        result.setTotalCount(this.countByQuery(query));
        result.setResult(this.selectByQuery(query));
        return result;
    }

    /**
     * select by primary key.
     */
    @Override
    public FlowSnapDO selectByPrimaryKey(Long id){
        return flowSnapExtMapper.selectByPrimaryKey(id);
    }

    /**
     * update by query condition selective.
     */
    @Override
    public int updateByQuerySelective( FlowSnapDO record,  FlowSnapQuery query){
        return flowSnapExtMapper.updateByQuerySelective(record,  query);
    }

    /**
     * update by query condition.
     */
    @Override
    public int updateByQuery( FlowSnapDO record,  FlowSnapQuery query){

        return flowSnapExtMapper.updateByQuery(record, query);
    }

    /**
     * update by primary key selective.
     */
    @Override
    public int updateByPrimaryKeySelective(FlowSnapDO record){
        return flowSnapExtMapper.updateByPrimaryKeySelective(record);
    }
}